]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Return error if stream creation failed
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 25 Jan 2021 11:32:26 +0000 (12:32 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 28 Jan 2021 21:47:50 +0000 (21:47 +0000)
When we fail for some reason to open a stream to write the screenshot
to, we currently return `false` to the sender. That's not wrong, but
doesn't provide any hints on what caused the failure, so return the
underlying error instead.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3618

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1589>

js/ui/screenshot.js

index 29cf7c8977e64266fa079c609d492a9c43153777..05120e1a2283ffaa4d71a271f332f35d6a01b14a 100644 (file)
@@ -108,22 +108,24 @@ var ScreenshotService = class {
                 let stream = file.replace(null, false, Gio.FileCreateFlags.NONE, null);
                 return [stream, file];
             } catch (e) {
-                invocation.return_value(GLib.Variant.new('(bs)', [false, '']));
+                invocation.return_gerror(e);
                 return [null, null];
             }
         }
 
+        let err;
         for (let file of this._resolveRelativeFilename(filename)) {
             try {
                 let stream = file.create(Gio.FileCreateFlags.NONE, null);
                 return [stream, file];
             } catch (e) {
+                err = e;
                 if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS))
                     break;
             }
         }
 
-        invocation.return_value(GLib.Variant.new('(bs)', [false, '']));
+        invocation.return_gerror(err);
         return [null, null];
     }